home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib25 / _extends.cpp < prev    next >
Text File  |  1992-09-29  |  3KB  |  114 lines

  1. |
  2. | single float to double float conversion routine
  3. |
  4.     .text
  5.     .even
  6.     .globl    __extendsfdf2, ___extendsfdf2
  7.  
  8. __extendsfdf2:
  9. ___extendsfdf2:
  10.  
  11. #ifndef    __M68881__
  12. # ifndef sfp004
  13. |
  14. | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  15. | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
  16. |
  17. | Revision 1.2, kub 01-90 :
  18. | added support for denormalized numbers
  19. |
  20. | Revision 1.1, kub 12-89 :
  21. | Ported over to 68k assembler
  22. |
  23. | Revision 1.0:
  24. | original 8088 code from P.S.Housel
  25.  
  26. BIAS4    =    0x7F-1
  27. BIAS8    =    0x3FF-1
  28.  
  29.     lea    sp@(4),a0    | parameter pointer
  30.     moveml    d2-d7,sp@-    | save regs to keep norm_df happy
  31.     movel    a0@,d4        | get number
  32.     clrl    d5        | prepare double mantissa
  33.  
  34.     movew    a0@,d0        | extract exponent
  35.     movew    d0,d2        | extract sign
  36.     lsrw    #7,d0
  37.     andw    #0xff,d0    | kill sign bit (exponent is 8 bits)
  38.  
  39.     andl    #0x7fffff,d4    | remove exponent from mantissa
  40.     tstw    d0        | check for zero exponent - no leading "1"
  41.     beq    0f        | for denormalized numbers
  42.     orl    #0x800000,d4    | restore implied leading "1"
  43.     bra    1f
  44. 0:    addw    #1,d0        | "normalize" exponent
  45. 1:
  46.     addw    #BIAS8-BIAS4-3,d0    | adjust bias, account for shift
  47.     clrw    d1        | dummy rounding info
  48.  
  49.     jmp    norm_df
  50.  
  51. # else    sfp004
  52.  
  53. | single precision floating point stuff for Atari-gcc using the SFP004
  54. | developed with gas
  55. |
  56. | single float to double float conversion routine
  57. |
  58. | M. Ritzert (mjr at dmzrzu71)
  59. |
  60. | 4.10.1990
  61. |
  62. | no NAN checking implemented since the 68881 treats this situation "correct",
  63. | i.e. according to IEEE
  64.  
  65. | addresses of the 68881 data port. This choice is fastest when much data is
  66. | transferred between the two processors.
  67.  
  68. comm =     -6
  69. resp =    -16
  70. zahl =      0
  71.  
  72. | waiting loop ...
  73. |
  74. | wait:
  75. | ww:    cmpiw    #0x8900,a1@(resp)
  76. |     beq    ww
  77. | is coded directly by
  78. |    .long    0x0c688900, 0xfff067f8
  79.  
  80.     lea    0xfffffa50:w,a0
  81.     movew    #0x4400,a0@(comm)    | load argument to fp0
  82.     cmpiw    #0x8900,a0@(resp)    | check
  83.     movel    a7@(4),a0@        | now push arg
  84.     movew    #0x7400,a0@(comm)    | result to d0/d1
  85.     .long    0x0c688900, 0xfff067f8
  86.     movel    a0@,d0            | pop double float
  87.     movel    a0@,d1
  88.     rts
  89.  
  90. # endif    sfp004
  91. #else    __M68881__
  92.  
  93. | mjr:    provided for safety. should be never called.
  94. |
  95. | single precision floating point stuff for Atari-gcc
  96. | developed with gas
  97. |
  98. | single float to double float conversion routine
  99. |
  100. | M. Ritzert (mjr at dfg.dbp.de)
  101. |
  102. | 4.10.1990
  103. | 11.11.1991
  104. |
  105. | no NAN checking implemented since the 68881 treats this situation "correct",
  106. | i.e. according to IEEE
  107.  
  108.     fmoves    a7@(4),fp0    | load argument to fp0
  109.     fmoved    fp0,a7@-    | read back as double
  110.     moveml    a7@+,d0-d1
  111.     rts
  112.  
  113. #endif    __M68881__
  114.